<?php
class X_Url
{
    static public function getCurrent($bForceSsl = false)
    {
        $sProtocol = ((array_key_exists('HTTPS', $_SERVER) && $_SERVER["HTTPS"] == "on") || $bForceSsl) ? 'https://' : 'http://';
     
        return $sProtocol . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'];
    }
    /**
     * handle situations where you need to use a leading ? in your rewrite rueles
     */
    static public function getSecondaryValues()
    {
    	$sQueryString = (strlen($_SERVER["QUERY_STRING"]) > strlen($_SERVER["REQUEST_URI"])) ? $_SERVER["QUERY_STRING"] : $_SERVER["REQUEST_URI"];
    	if (strpos($sQueryString, '?'))
    	{
    		$aReturn = array();
    		$aQueries = explode('?', $sQueryString);
    		$aKeyValuePairs = explode('&', $aQueries[1]);
    		foreach ($aKeyValuePairs as $sPair)
    		{
    			$aKeyValue = explode('=', $sPair);
    			$aReturn[$aKeyValue[0]] = $aKeyValue[1];
    		}
    		return $aReturn;
    	}
    	
    	return array();
    }
}